import React, {
    Component,
} from 'react';
import {
    StyleSheet,
    Text,
    View,
    Dimensions,
    TouchableOpacity,
    Image,
    ScrollView,
    Clipboard,
    Platform
} from 'react-native';
import AndroidModule from '../../../utils/AndroidConnent'

const isIos = Platform.OS == 'ios';


export default class CarListShareBox extends Component {

    constructor(props) {
        super(props);
        this.state = {
            isWxAppInstall: true
        }
    }

    componentDidMount() {
        if (isIos) {
            AndroidModule.isWxAppInstall({}, (error, result) => {
                let isWxAppInstall = result.isWxAppInstall
                this.setState({
                    isWxAppInstall: isWxAppInstall
                })
            })
        }
    }

    render() {
        return (
            <TouchableOpacity
                activeOpacity={1}
                style={styles.container}
                onPress={() => {
                    if (this.props.closeHandler) {
                        this.props.closeHandler()
                    }
                }}
            >
                <View>
                    {
                        this.state.isWxAppInstall ?
                            <TouchableOpacity style={styles.listShareContain}
                                onPress={() => {
                                    if (this.props.shareTypeHandler) {
                                        this.props.shareTypeHandler(1)
                                    }
                                }}>
                                <Image style={styles.listShareIcon} source={require('source/image/car/ic_list_share_list.png')}></Image>
                                <View style={{ marginLeft: 10 }}>
                                    <Text style={styles.listShareTitle}>列表分享</Text>
                                    <Text style={styles.listShareContent}>分享列表内容</Text>
                                </View>
                            </TouchableOpacity>
                            :
                            null
                    }


                    <TouchableOpacity style={[styles.listShareContain, { marginTop: 30 }]}
                        onPress={() => {
                            if (this.props.shareTypeHandler) {
                                this.props.shareTypeHandler(2)
                            }
                        }
                        }>
                        <Image style={styles.listShareIcon} source={require('source/image/car/ic_list_multi_share.png')}></Image>
                        <View style={{ marginLeft: 10 }}>
                            <Text style={styles.listShareTitle}>多车辆分享</Text>
                            <Text style={styles.listShareContent}>多台车辆进行分享</Text>
                        </View>
                    </TouchableOpacity>
                </View>
            </TouchableOpacity>
        )
    }


}

const styles = StyleSheet.create({
    container: {
        position: 'absolute',
        top: 0, bottom: 0, left: 0, right: 0,
        backgroundColor: 'rgba(255,255,255,0.9)',
        justifyContent: 'center',
        alignItems: 'center'
    },
    listShareContain: {
        flexDirection: 'row',
        alignItems: 'center',
    },
    listShareTitle: {
        fontSize: 16,
        color: '#333333'
    },
    listShareContent: {
        fontSize: 14,
        color: '#666666',
        marginTop: 8
    },
    listShareIcon: {
        width: 50,
        height: 50
    },

})